/*
============================================================================
 Name        : BlockMenu.h
 Author      : 
 Version     :
 Copyright   : 
 Description : CBlockMenu declaration
============================================================================
*/

#ifndef MENU_H
#define MENU_H

// INCLUDES
#include "Block.h"
#include "Flickable.h"

const TInt KMainMenuItemNumbers = 12;

class TMenuItem
{
public:
	TInt m_nID;
	TBuf<16> m_strMenu;
};
// CLASS DECLARATION

/**
*  CBlockMenu
* 
*/
class CBlockMenu : public CBlock, MFlickableCallback
{
public:
	~CBlockMenu();

	static CBlockMenu* NewL(CBaseBlock* bsBack);

	static CBlockMenu* NewLC(CBaseBlock* bsBack);

	CBlockMenu(CBaseBlock* bsBack);

private:
	void ConstructL();

public://from CBlock
	virtual void OnDraw(CFbsBitGc& g) const;
	
	virtual void OnOK(TInt nNewID);

	virtual void OnCancel();

	virtual void OnKeyDown(TInt keyCode);

	virtual void OnInput(const TDesC8& strInput);

	TBool Initial(TInt nID);
	
	void ChangeScrollPos(TInt nPos);
	
	void OnMouseDown(const TPoint& aPt);
	
	void OnMouseMove(const TPoint& aPt);
	
	void OnMouseUp(const TPoint& aPt);
	
	void SizeChanged();

	void SetScrollBar(TInt nPos, TInt nRange);
	
	void ChangeFocus(TBool aFoucs, const TInt& keyCode);
	
	void BeforeBack();
	
	void HandleTitlebarCommand(TInt aCommand);
	
public:
    // from MFlickableCallback
    virtual TPoint ScrollOffset() const;

    virtual void SetScrollOffset(const TPoint& aOffset);

private:
	//new functions
	void AddMenuItem(const TDesC& strMenu);

	void AddMenuItem(const TDesC& strMenu, TInt nID);
	
	void AddMenuItemFromRes(const TInt& resID);

	void AddMenuItemFromRes(const TInt& resID, TInt nID);

	TInt FindMenuItem(int nID);
	
	void LoadImages();

	void DrawPicMenu(CFbsBitGc& g) const;

	void InitPopMenu(const TInt& nType);

	TBool OnMenuEvent(TInt menuId);

protected:
	void BeforeDraw(CFbsBitGc& g) const;

public:
	TInt m_nType;
	TInt32 m_nAskType;
	TInt m_nID;
	RArray<TMenuItem> m_aItem;
	TInt m_nCurrentItem;
	TInt m_oriCurrentItem;
	TInt m_nMaxWidth;
	CBlock* m_blockReturn;
	TInt m_nMenuItem;
	TInt m_psInfoID[13]; 
	CDesCArray* m_pstrInfoName;
	TInt m_psInfoID2[5];
	CDesCArray* m_pstrInfoName2;
	CFbsBitmap* m_aImages[KMainMenuItemNumbers];
	CFbsBitmap* m_aImagesSel[KMainMenuItemNumbers];
	TInt m_nStart;

	TInt m_psNBSID[5];
	CDesCArray* m_pstrNBS;
	TInt m_nHelpSubType;
	

    TInt iOffset;
    TInt iHeight;
    TInt iHighlight;
    CFlickable* iFlickable;
    TRect iListRect;

    mutable TInt iStartItem;
    mutable TInt iEndItem;
};

#endif // MENU_H
